package cn.iocoder.yudao.module.member.dal.mysql.profit;

import java.util.*;

import cn.hutool.core.util.ObjectUtil;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.member.controller.admin.profit.vo.ProfitMainPageReqVO;
import cn.iocoder.yudao.module.member.dal.dataobject.profit.ProfitMainDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 利润报 Mapper
 *
 * @author base
 */
@Mapper
public interface ProfitMainMapper extends BaseMapperX<ProfitMainDO> {

    default PageResult<ProfitMainDO> selectPage(ProfitMainPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ProfitMainDO>()
                .eqIfPresent(ProfitMainDO::getPrivatePoolCost, reqVO.getPrivatePoolCost())
                .eqIfPresent(ProfitMainDO::getPrivatePoolSales, reqVO.getPrivatePoolSales())
                .eqIfPresent(ProfitMainDO::getDeviceCost, reqVO.getDeviceCost())
                .eqIfPresent(ProfitMainDO::getDeviceSales, reqVO.getDeviceSales())
                .eqIfPresent(ProfitMainDO::getCertificateCost, reqVO.getCertificateCost())
                .eqIfPresent(ProfitMainDO::getCertificateSales, reqVO.getCertificateSales())
                .eqIfPresent(ProfitMainDO::getTotalProfit, reqVO.getTotalProfit())
                .eqIfPresent(ProfitMainDO::getTotalCost, reqVO.getTotalCost())
                .eqIfPresent(ProfitMainDO::getTotalSales, reqVO.getTotalSales())
                .like( !ObjectUtil.isNull(reqVO.getProfitTime()),  ProfitMainDO::getProfitTime, reqVO.getProfitTime())
                .orderByDesc(ProfitMainDO::getId));
    }

}
